<?php

/**
 * This is the model class for table "{{deporte_actividad}}".
 *
 * The followings are the available columns in table '{{deporte_actividad}}':
 * @property integer $deporte_actividad_id
 * @property string $deporte_actividad_descripcion
 * @property string $deporte_actividad_observacion
 * @property string $deporte_actividad
 *
 * The followings are the available model relations:
 * @property InscripcionNominal[] $inscripcionNominals
 */
class DeporteActividad extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return DeporteActividad the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{deporte_actividad}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('deporte_actividad_descripcion', 'required'),
			array('deporte_actividad_descripcion', 'length', 'max'=>50),
			array('deporte_actividad_observacion', 'length', 'max'=>200),
			array('deporte_actividad', 'length', 'max'=>1),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('deporte_actividad_id, deporte_actividad_descripcion, deporte_actividad_observacion, deporte_actividad', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inscripcionNominals' => array(self::HAS_MANY, 'InscripcionNominal', 'inscripcion_nominal_deporte_actividad'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'deporte_actividad_id' => 'Deporte Actividad',
			'deporte_actividad_descripcion' => 'Deporte Actividad Descripcion',
			'deporte_actividad_observacion' => 'Deporte Actividad Observacion',
			'deporte_actividad' => 'Deporte Actividad',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('deporte_actividad_id',$this->deporte_actividad_id);
		$criteria->compare('deporte_actividad_descripcion',$this->deporte_actividad_descripcion,true);
		$criteria->compare('deporte_actividad_observacion',$this->deporte_actividad_observacion,true);
		$criteria->compare('deporte_actividad',$this->deporte_actividad,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}